-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enabling c++20 on linux #17816
base: main
Are you sure you want to change the base?
Enabling c++20 on linux #17816
Conversation
…ERTY LINK_FLAGS " -s ASSERTIONS=2 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=2")"
…ING PROPERTY LINK_FLAGS " -s ASSERTIONS=2 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=2")"" This reverts commit c72c40e.
We cannot do it for Linux CUDA build yet. Because the compiler we use is GCC 8, which is too low. |
Just out of curiosity. Why do you need C++20? Would it crash onnxruntime build in my old conda environment? |
For your second question, no. A new C++ standard consists of two things:
The first one doesn't have impact on compatibility. The second one has impacts on non-Windows/non-Linux systems like macOS/iOS. We can avoid the issue by not using the headers that are not supported by the target system. |
Wait this #20786 . The PR will update all GCCs to >=11. Now we still have GCC 8. |
The GCC version is updated. |
We can use the new C++ features to write better code, and it shouldn't impact our compatibility at runtime. The language features are listed in https://gcc.gnu.org/projects/cxx-status.html in "C++20 Language Features" section |
@@ -326,11 +326,11 @@ class TreeAggregatorMin : public TreeAggregator<InputType, ThresholdType, Output | |||
template <typename InputType, typename ThresholdType, typename OutputType> | |||
class TreeAggregatorMax : public TreeAggregator<InputType, ThresholdType, OutputType> { | |||
public: | |||
TreeAggregatorMax<InputType, ThresholdType, OutputType>(size_t n_trees, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All other similar class like TreeAggregatorMin and TreeAggregatorSum does not include type qualifier.
depends on #21071 |
…nux_c++20 # Conflicts: # onnxruntime/contrib_ops/cuda/math/cufft_plan_cache.h # orttraining/orttraining/training_ops/cuda/nn/conv_shared.h # orttraining/orttraining/training_ops/rocm/nn/conv_grad.cc
for (size_t x = 0; x < body; x++) { volatile_x = x; // Your code here, using volatile_x if necessary }
#pragma GCC diagnostic ignored "-Wdeprecated"
#pragma GCC diagnostic ignored "-Wdeprecated"
#pragma clang diagnostic pop #endif
# Conflicts: # onnxruntime/core/providers/cpu/ml/tree_ensemble_aggregator.h
@@ -108,7 +108,14 @@ std::cv_status OrtCondVar::wait_for(std::unique_lock<OrtMutex>& cond_mutex, | |||
namespace onnxruntime { | |||
|
|||
class OrtMutex { | |||
#if defined(__clang__) && __cplusplus >= 202002L | |||
#pragma clang diagnostic push | |||
#pragma clang diagnostic ignored "-Wdeprecated-pragma" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be fixed - see this patch: e34c91c
@@ -87,7 +87,18 @@ Status EmbedLayerNorm<T>::Compute(OpKernelContext* context) const { | |||
|
|||
int n = batch_size * sequence_length; | |||
concurrency::ThreadPool::TryBatchParallelFor( | |||
#if __cplusplus >= 202002L | |||
context->GetOperatorThreadPool(), n, [=, this, &failed](ptrdiff_t index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see this core guideline:
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f54-when-writing-a-lambda-that-captures-this-or-any-class-data-member-dont-use--default-capture
I think they have a point. at least, we should consider how to make the code easier to understand.
Now we are using NDK 27? |
Description
Enabling c++20 on Linux
Currently blocking issue:
Motivation and Context
We want the latest and the greatest features from c++20.
depends on